package com.etc.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.etc.dao.FosterFamilyMapper;
import com.etc.entity.FU;
import com.etc.entity.FosterFamily;
import com.etc.tools.PageData;

@Service(value = "fosterFamilyService")
public class FosterFamilyServiceImpl implements com.etc.service.FosterFamilyService {
	@Resource
	private FosterFamilyMapper ffm;

	@Override
	public FosterFamily getFosterFamilyById(int fid) {
		// TODO Auto-generated method stub
		return ffm.selectByPrimaryKey(fid);
	}
	@Override
	public List<FosterFamily> getFosterFamilyByfuid(int fuid) {
		// TODO Auto-generated method stub
		return (List<FosterFamily>) ffm.selectByfuid(fuid);
	}

	@Override
	public boolean addFosterFamily(FosterFamily fosterFamily) {
		// TODO Auto-generated method stub
		return ffm.insert(fosterFamily) > 0;
	}

	@Override
	public PageData<FU> getFosterFamilysByPage(int page, int pageSize, String content) {
		// TODO Auto-generated method stub
		int start = (page - 1) * pageSize;
		List<FU> data = ffm.selectFosterFamilyBypage(start, pageSize, content);
		int count = ffm.selectCount(content);
		PageData<FU> pageData = new PageData<>(data, count, pageSize, page);
		return pageData;
	}
	@Override
	public PageData<FU> getFosterFamilysByPage1(int page, int pageSize, String content) {
		// TODO Auto-generated method stub
		int start = (page - 1) * pageSize;
		List<FU> data = ffm.selectFosterFamilyBypage1(start, pageSize, content);
		int count = ffm.selectCount1(content);
		PageData<FU> pageData = new PageData<>(data, count, pageSize, page);
		return pageData;
	}

	@Override
	public boolean delFosterFamily(int fid) {
		// TODO Auto-generated method stub
		return ffm.deleteByPrimaryKey(fid)>0;
	}

	@Override
	public boolean updateFosterFamily(FosterFamily fosterFamily) {
		// TODO Auto-generated method stub
		return ffm.updateByPrimaryKey(fosterFamily)>0;
	}
	@Override
	public List<FU> selectAllFosterFamily() {
		
		return ffm.selectAllFosterFamily();
	}

}
